#include <config.h>
#include <video_manager.h>
#include <convert_manager.h>

static PT_VideoConvert g_ptConvertHead = NULL;

int RegisterVideoConvert(PT_VideoConvert ptVideoConvert)
{
    if(!g_ptConvertHead)
    {
        g_ptConvertHead = ptVideoConvert;
        g_ptConvertHead->ptNext = NULL;
    }
    else
    {
        PT_VideoConvert ptTmp = g_ptConvertHead;
        while(ptTmp->ptNext)
        {
            ptTmp = ptTmp->ptNext;
        }
        ptTmp->ptNext = ptVideoConvert;
        ptVideoConvert->ptNext = NULL;
    }
    return 0;
}

PT_VideoConvert GetVideoConvertForFormats(int iPixelFormatIn, int iPixelFormatOut)
{
    PT_VideoConvert ptTmp = g_ptConvertHead;
    while(ptTmp)
    {
        if(ptTmp->isSupport(iPixelFormatIn, iPixelFormatOut) == 0)  //是否支持这种格式的转换
        {
            printf("Support Convert: %s\n", ptTmp->name);
            return ptTmp;   //是则返回对应的转换函数
        }
        ptTmp = ptTmp->ptNext;
    }
    return NULL;
}



int VideoConvertInit(void)
{
    int ret;

    ret = Yuv2RgbInit();
    ret |= Mjpeg2RgbInit();
    ret |= Rgb2RgbInit();

    return ret;
}
